package com.sskj.mine.util;

import com.google.gson.Gson;

import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * author : lxl
 * date : 2019/8/8
 * description : 将map转化为json类型的body
 */
public class MapToJsonUtils {

    public static RequestBody mapToJson(Map<String, Object> map) {

        Gson gson = new Gson();
        String json = gson.toJson(map);
        MediaType JSON = MediaType.parse("application/json; charset=utf-8");
        RequestBody body = RequestBody.create(JSON, json);
        return body;
    }
}
